        	//
//  CalculateViewController.m
//  Umoney
//
//  Created by zwz on 16/8/30.
//  Copyright © 2016年 zhangwz. All rights reserved.
//

#import "CalculateViewController.h"

@interface CalculateViewController ()<UITextFieldDelegate>
{
    IBOutlet UITextField *InvestMoney;
    IBOutlet UITextField *Rate;
    IBOutlet UITextField *Day;
    IBOutlet UILabel *Earning;
    IBOutlet UILabel *Total;
}

@end

@implementation CalculateViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self addGesture];
    // Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)DoCalculate:(id)sender {
    float invest= [InvestMoney.text floatValue];
    float rate = [Rate.text floatValue];
    float day = [Day.text floatValue];
    float earning,total;
    earning = invest*rate*day/36500;
    total = invest+earning;
    Earning.text = [NSString stringWithFormat:@"%.2f",earning];
    Total.text = [NSString stringWithFormat:@"%.2f",total];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

-(void)addGesture
{
    UITapGestureRecognizer *tap1=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(viewtaped:)];
    tap1.cancelsTouchesInView=NO;
    [self.view addGestureRecognizer:tap1];
}


-(void)viewtaped:(UIGestureRecognizer *)tap1
{
    [self.view endEditing:YES];
}

-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    return YES;
}

@end
                            	